<?php

namespace App\Http\Controllers\Front;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

use App\Http\Model\Activity;
use App\Http\Model\Join;
use App\Http\Model\Info;

class IndexController extends Controller
{

    public function __construct(Request $request){

        if (!$request->session()->has('info')) {
            
            $request->session()->put('info', Info::find(1));
        }
    }
    /**
     * 首页
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {
        $data = array();

        $data['info'] = $request->session()->get('info');

        return view('Front.index.index', $data);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function join(Request $request)
    {
        $data = array();
        $data['joins'] = Join::all();
        $data['info'] = $request->session()->get('info');

        return view('Front.index.join', $data);
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function activity(Request $request)
    {
        $data = array();

        $data['activitys'] = Activity::orderBy('date_time', 'DESC')->get();
        $data['info'] = $request->session()->get('info');

        return view('Front.index.activity', $data);
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function jtpk(Request $request)
    {
        $data = array();

        $data['info'] = $request->session()->get('info');

        return view('Front.index.jtpk', $data);
    }

    public function contact(Request $request)
    {
        $data = array();
        
        $data['info'] = $request->session()->get('info');

        return view('Front.index.contact', $data);
    }
    
    public function introduce(Request $request)
    {
        $data = array();
        
        $data['info'] = $request->session()->get('info');

        return view('Front.index.introduce', $data);
    }


}
